#include "AvmSdk.h"
#include <string.h>
#include <utils/Log.h>
#ifdef LOG_TAG
#undef LOG_TAG
#define LOG_TAG "SVPMain"
#endif

#ifdef LOG_NDEBUG
#undef LOG_NDEBUG
#define LOG_NDEBUG 0
#endif

/**
 * @brief 
 * avm状态回调
 * type： 回调信号ID 范围 emD2AType中所有枚举
 * val    当前信号ID状态值
 * 
 */
void _AvmSdk_ReceiveData(int type, const std::vector<int> &val)
{
	ALOGW("%d,%d", type, val[0]);
}

/**
 * @brief 
 * 车身信号状态回调
 * 该回调会回调stCanData结构体中所有的车身信号，每当其中一个信号有变化时就会整体回调
 * 
 * 
 */
void _AvmSdk_CanData(const stCanData &val)
{
	ALOGW("BCM_BrakeLightSwitchSt %d", val.BCM_BrakeLightSwitchSt);
}

int main()
{

	AvmSdk_Init(_AvmSdk_ReceiveData, _AvmSdk_CanData); //初始化车身通讯，并注册回调

	std::vector<int> val;
	val.push_back(3);
	AvmSdk_SendData(A2D_RunningStatus, val); //发送emA2DType枚举中的信号示例

	val.clear();
	char const *version = "v_chenqiulong";
	for (unsigned int i = 0; i < strlen(version); i++)
	{
		val.push_back(version[i]);
	}
	AvmSdk_SendData(A2D_SoftwareVersion, val); //发送emA2DType枚举中的信号示例

	std::vector<int32_t> configVal;
	AvmSdk_GetData(D2AGet_VehicleConfig,configVal);

	int count = configVal.size();
	for (int i = 0; i < count; i++)
	{
		printf("%02X ", configVal[i]);
	}


	while (true) //死循环用于防止进程退出 后续可以开发输入不同值发送不同信号的功能。
	{
		printf("\n0~18 \n");
		printf("1 A2D_RunningStatus\n");
		printf("2 A2D_WorkMode\n");
		printf("3 A2D_SoftwareVersion\n");
		printf("4 A2D_DirLampOpenSvm\n");
		printf("5 A2D_RadarOpenSvm\n");
		printf("6 A2D_SnapshotStatus\n");
		printf("7 A2D_DispStatus\n");
		printf("8 A2D_EnterCalibrationResp\n");
		printf("9 A2D_EnterCalibrationResultResp\n");
		printf("10 A2D_CalibrationPreCheckResp\n");
		printf("11 A2D_CalibrationPreCheckResultResp\n");
		printf("12 A2D_StartCalibrationResp\n");
		printf("13 A2D_StartCalibrationResultResp\n");
		printf("14 A2D_EnterCalibrationFailResp\n");
		printf("15 A2D_EnterCalibrationFailResultResp\n");
		printf("16 A2D_EnterCalibrationCheckResp\n");
		printf("17 A2D_EnterCalibrationCheckResultResp\n");
		printf("18 A2D_OSRMAngleAdjFuncCfg\n");
		std::string result;
		int inputkey;
		scanf("%d", &inputkey);
		printf("输出： %d \n", inputkey);
		std::vector<int> val;
		switch (inputkey)
		{
		case 1:
			val.push_back(inputkey);
			AvmSdk_SendData(A2D_RunningStatus, val);
			break;
		case 2:
			val.push_back(inputkey);
			AvmSdk_SendData(A2D_WorkMode, val);
			break;
		case 3:
			val.push_back(inputkey);
			AvmSdk_SendData(A2D_SoftwareVersion, val);
			break;
		case 4:
			val.push_back(inputkey);
			AvmSdk_SendData(A2D_DirLampOpenSvm, val);
			break;
		case 5:
			val.push_back(inputkey);
			AvmSdk_SendData(A2D_RadarOpenSvm, val);
			break;
		case 6:
			val.push_back(inputkey);
			AvmSdk_SendData(A2D_SnapshotStatus, val);
			break;

		case 7:
			val.push_back(inputkey);
			AvmSdk_SendData(A2D_DispStatus, val);
			break;
		case 8:
			val.push_back(inputkey);
			AvmSdk_SendData(A2D_EnterCalibrationResp, val);
			break;
		case 9:
			val.push_back(inputkey);
			AvmSdk_SendData(A2D_EnterCalibrationResultResp, val);
			break;
		case 10:
			val.push_back(inputkey);
			AvmSdk_SendData(A2D_CalibrationPreCheckResp, val);
			break;
		case 11:
			val.push_back(inputkey);
			AvmSdk_SendData(A2D_CalibrationPreCheckResultResp, val);
			break;
		case 12:
			val.push_back(inputkey);
			AvmSdk_SendData(A2D_StartCalibrationResp, val);
			break;
		case 13:
			val.push_back(inputkey);
			AvmSdk_SendData(A2D_StartCalibrationResultResp, val);
			break;
		case 14:
			val.push_back(inputkey);
			AvmSdk_SendData(A2D_EnterCalibrationFailResp, val);
			break;
		case 15:
			val.push_back(inputkey);
			AvmSdk_SendData(A2D_EnterCalibrationFailResultResp, val);
			break;
		case 16:
			val.push_back(inputkey);
			AvmSdk_SendData(A2D_EnterCalibrationCheckResp, val);
			break;
		case 17:
			val.push_back(inputkey);
			AvmSdk_SendData(A2D_EnterCalibrationCheckResultResp, val);
			break;
		case 18:
			val.push_back(inputkey);
			AvmSdk_SendData(A2D_OSRMAngleAdjFuncCfg, val);
			break;
		case 19:
			val.push_back(0);
			val.push_back(0);
			AvmSdk_SendData(A2D_CAMERAPOWERSUPPLY, val);
			break;
		case 20:
			val.push_back(0);
			val.push_back(0xfffe);
			AvmSdk_SendData(A2D_CAMERAPOWERSUPPLY, val);
			break;
		default:
			break;
		}
	}
	//  */
	return 0;
}
